<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>暗黑3评价平台后台管理</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/css/layout.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/css/common.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/management/css/list.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/javascript/plugins/boxy/boxy.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/jquery.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/management/javascript/operation.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/plugins/boxy/jquery.boxy.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/plugins/jquery.extcloudSlideMenu.js"></script>
<%@include file="/WEB-INF/view/commonJavascriptVar.jsp"%>
<script type="text/javascript">
$(function() {
	$("li.layout_search_pull_ss a").extcloudSlideMenu({
		init_hideMenu: true ,
		speed: "fast"
	}) ;
});


function addItem(name,id) {
	var callback = function(){
		var rowNum=$("#equipmentTable tr").length - 1;
		var rowData = "<tr><td><a href='" 
			+ context 
			+ "/management/cte/preupdate/" + id + "'>" 
			+ name + "</a></td><td><a href='javascript:void(0);' onclick=javascript:deleteItem('"+id+"',this);>删除</a></td></tr>";
		$(rowData).insertAfter($("#equipmentTable tr:eq("+rowNum+")"));
	};
	ajaxAdd(id,callback) ;
}
function ajaxAdd(id,callback) {
	var ajaxParams = {} ;
	var url = context + "/management/cte/ajaxadd/${category.categoryId}_" + id ;
	$.get(url, ajaxParams,
			function(data, textStatus, jqXHR) {
				if (textStatus == "success") {
					if(data.error) {
						alert(data.info) ;
						return false;
					} else if(data.success) {
						callback();
						alert(data.info) ;
						return true ;
					} else {
						alert("出现未知异常.") ;
						return false ;
					}
				}
	}, "json");
}
function add() {
	Boxy.load(context+'/management/search/equipment/presearchforcte',{unloadOnHide:true,title:'增加物品'});
}

function changeCategorySort(categoryId,element) {
	var sort = $(element).parent().find("input").val();
	ajaxChangeCategorySort(categoryId,sort);
}
function ajaxChangeCategorySort(categoryId,sort) {
	var ajaxParams = {sss:Math.random()*1000000};
	var url = context + "/management/category/ajaxchangecategorysort/" + categoryId + "_" + sort;
	$.post(url, ajaxParams,
			function(data, textStatus, jqXHR) {
				if (textStatus == "success") {
					if(data.error) {
						alert(data.info) ;
						return false;
					} else if(data.success) {
						alert(data.info);
						return true ;
					} else {
						alert("出现未知异常.") ;
						return false ;
					}
				}
	}, "json");
}
</script>
</head>
<body>
<div id="layoutAll">
<table cellpadding="0" cellspacing="0" width="100%" id="layout_content">
	<tr>
		<td height="100" valign="top">
		<div id="layout_title">
		<h4>物品分类</h4>
		</div>
		<div id="layout_search">
		<p>&nbsp;</p>
		</div>
		<div id="layout_search_pull">
		<ul>
			<c:if
				test="${category.superCategory!=null && fn:length(category.superCategory.categoryId)>0}">
				<li><a
					href="${pageContext.request.contextPath}/management/category/view/${category.superCategory.categoryId}">回到上一级</a></li>
				<li><img
					src="${pageContext.request.contextPath}/common/images/menufg.jpg" /></li>
			</c:if>
			<li><a
				href="${pageContext.request.contextPath}/management/category/preadd/${category.categoryId}">增加子分类</a></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" /></li>
			<li><a onclick="javascript:add();" href="javascript:void(0);">增加物品</a><!--<a 
				href="${pageContext.request.contextPath}/management/cte/preupdate/${category.categoryId}">增加物品</a>--></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" /></li>
			<li class="layout_search_pull_ss"><a href="#"><img
				src="${pageContext.request.contextPath}/common/images/menu_up.gif" /></a></li>
		</ul>
		</div>
		</td>
	</tr>
	<tr>
		<td valign="top">
		<div id="layout_content_body">
		<h1 align="center">分类信息查看</h1>
		<center>
		<div style="text-align: left"><c:if
			test="${category.superCategory!=null}">
		</c:if></div>
		<form id="backForm" action="" method="post">
		<table align="center" width="90%" border="1px" bordercolor="#D4D4D4"
			cellspacing="0px">
			<tbody>
				<tr>
					<td width="10%">分类名称</td>
					<td>${category.categoryName }</td>
				</tr>
				<tr>
					<td>分类描述</td>
					<td>${category.categoryDescription }</td>
				</tr>
				<tr>
					<td colspan="2">子分类</td>
				</tr>
			</tbody>
		</table>
		<table align="center" width="90%" border="1px" bordercolor="#D4D4D4"
			cellspacing="0px">
			<thead>
				<tr>
					<th>序号</th>
					<th>条目名称</th>
					<th>操作</th>
					<th>排序</th>
				</tr>
			</thead>
			<c:forEach items="${category.subCategorys}" var="category"
				varStatus="status">
				<tr>
					<td class="center">${status.index + 1 }&nbsp;&nbsp;<input
						type="checkbox" name="ids" id="ids" value="${category.categoryId}" /></td>
					<td><a title="${category.categoryDescription}"
						href="${category.categoryId}">${category.categoryName}</a></td>
					<td><a
						href="${pageContext.request.contextPath}/management/category/preupdate/${category.categoryId}">修改</a>
					<a
						href="${pageContext.request.contextPath}/management/category/delete/${category.categoryId}">删除</a></td>
					<td><input style="width: 20px;" value="${category.sort}" /><a
						href="javascript:void(0);"
						onclick="javascript:changeCategorySort('${category.categoryId}',this);">修改</a></td>
				</tr>
			</c:forEach>
		</table>
		<table align="center" width="90%" border="1px" bordercolor="#D4D4D4"
			cellspacing="0px">
			<tbody>
				<tr>
					<td colspan="2">物品</td>
				</tr>
			</tbody>
		</table>
		<table id="equipmentTable" align="center" width="90%" border="1px"
			bordercolor="#D4D4D4" cellspacing="0px">
			<thead>
				<tr>
					<th>序号</th>
					<th>物品名称</th>
					<th>操作</th>
					<th>排序</th>
				</tr>
			</thead>
			<c:forEach items="${category.CTEs}" var="CTE" varStatus="status">
				<tr>
					<td class="center">${status.index + 1 }&nbsp;&nbsp;<input
						type="checkbox" name="ids2" id="ids2" value="${CTE.id}" /></td>
					<td><a title="${CTE.equipment.equipmentDescription}"
						href="${pageContext.request.contextPath}/management/equipment/preupdate/${CTE.equipment.equipmentId}">${CTE.equipment.equipmentName}</a></td>
					<td><a href="javascript:void(0);"
						onclick="javascript:$(this).parent().parent().find('#ids2').attr('checked','checked');del('${pageContext.request.contextPath}/management/cte/ajaxdelete/','ids2');">删除</a></td>
					<td><input style="width: 20px;" value="${CTE.sort}" /><a
						href="javascript:void(0);"
						onclick="javascript:changeCategorySort('${category.categoryId}',this);">修改</a></td>
				</tr>
			</c:forEach>
		</table>
		</form>
		</center>
		</div>
		</td>
	</tr>
</table>
</div>
</body>